<template>
    <div>
    <yd-cell-item>
        <span slot="left">联系电话</span>
        <!--<yd-input slot="right" v-model="phone" regex="mobile" style="text-align: right;color: #262626;font-size: 0.25rem" placeholder="手机号码"></yd-input>-->

        <input slot="right" placeholder="手机号码"  type="number" style="text-align: right;color: #262626;font-size: 0.25rem"  v-model="phone" maxlength="11">

    </yd-cell-item>
        <yd-cell-item>
            <span slot="left">机构/部门地址</span>
            <textarea slot="right" cols="3" rows="3" maxlength="100" v-model="address" placeholder="详细到门牌号"
                      style="height: 100%;width: 80%;border: 0px solid #e6e6e6;color: #262626;font-size: 0.25rem;text-align: right;padding-top: 10px">
       </textarea>
        <!--<input slot="right" type="text" style="text-align: right;padding: 0 0 0 0.2rem" v-model="address">-->
    </yd-cell-item>
    <yd-cell-item>
        <span slot="left">房间号</span>
        <input slot="right" type="text" style="text-align: right;color: #262626;font-size: 0.25rem" v-model="room" placeholder="具体房间号">
    </yd-cell-item>

        <yd-button v-if="isShow" size="large" type="primary" @click.native="confrimClick" style="background-color:#e9b778;color:white">确定</yd-button>
        <yd-button v-if="!isShow" size="large" type="primary" @click.native="confrimClick" style="background-color:#83d16f;color:white">确定</yd-button>

    </div>
</template>

<script>
    import {userInfoData} from '../../globalVariables'

    export default {
        name: "editAddress",
        data() {
            return {
                phone:JSON.parse(localStorage.getItem('phone')),
                address:JSON.parse(localStorage.getItem('address')),
                room:JSON.parse(localStorage.getItem('room')),
                type:'1',
                isShow:true,

            };
        },
        methods:{
            confrimClick ()
            {
                if (this.phone ===''||this.phone.length<11)
                {
                    this.$dialog.toast({
                        mes: '手机号输入有误！',
                        timeout: 1500
                    });
                    return;
                }
                if (this.address ===''||this.address===null)
                {
                    this.$dialog.toast({
                        mes: '请填写送货地址！',
                        timeout: 1500
                    });
                    return;
                }
                localStorage.setItem('room',JSON.stringify
                    (this.room));
                localStorage.setItem('phone',JSON.stringify
                (this.phone));
                localStorage.setItem('address',JSON.stringify
                (this.address));
                this.$router.back(-1);


            }
        },
        created()
        {
            ////type 1 是办公用品 2是凭证请领
            this.type = this.$route.params.type;
            console.log(JSON.parse(localStorage.getItem('room')));
            console.log(this.type);
            if (this.type ==='1')
            {
                this.isShow=true;
            }else
            {
                this.isShow=false;

            }

        }


    }
</script>

<style lang='scss'>

</style>